import request from '../utils/request';

// 预警管理相关API
export const warningApi = {
  // 手动触发预警检查
  triggerWarningCheck: () => {
    return request.post('/api/warning/check');
  },

  // 获取预警列表
  getWarningList: (params) => {
    return request.get('/api/warning/list', { params });
  },

  // 获取预警统计
  getWarningStatistics: () => {
    return request.get('/api/warning/statistics');
  },

  // 获取预警详情
  getWarningDetail: (id) => {
    return request.get(`/api/warning/${id}`);
  },

  // 处理预警
  handleWarning: (id, remark) => {
    return request.post(`/api/warning/${id}/handle`, null, {
      params: { remark }
    });
  },

  // 忽略预警
  ignoreWarning: (id, remark) => {
    return request.post(`/api/warning/${id}/ignore`, null, {
      params: { remark }
    });
  },

  // 批量处理预警
  batchHandleWarning: (ids, remark) => {
    return request.post('/api/warning/batch/handle', {
      ids,
      remark
    });
  },

  // 获取预警规则列表
  getWarningRules: () => {
    return request.get('/api/warning/rules');
  },

  // 启用/禁用预警规则
  toggleWarningRule: (id) => {
    return request.post(`/api/warning/rules/${id}/toggle`);
  },

  // 清理历史预警
  cleanupWarnings: () => {
    return request.delete('/api/warning/cleanup');
  },

  // 清除所有预警
  clearAllWarnings: () => {
    return request.post('/api/warning/clear');
  }
};
